package com.example.videopractice

import com.google.gson.Gson
import org.junit.Test

import org.junit.Assert.*
import java.io.File
import java.util.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    @Test
    fun test() {
        val path = "C:\\Users\\xiao\\Desktop\\0614.json"
        val file = File(path)
        val strBuild = StringBuilder()
        file.useLines {
            it.forEach { str ->
                strBuild.append(str)
            }
        }
        val data = Gson().fromJson(strBuild.toString(), TaskAssignData::class.java)
        println(data)
    }

    data class TaskAssignData @JvmOverloads constructor(
        val code: String = "",
        val data: TaskAssign = TaskAssign()
    ) {
        data class TaskAssign(
            val assignmentId: String = "",
            val picUploadUrl: String = "",
            val routeInfo: RouteInfo = RouteInfo()
        )

        data class RouteInfo(
            val routeId: String = "",
            val altitude: Double = 0.0,
            val autoFlightSpeed: Double = 0.0,
            val actionOnFinish: String = "",
            val headingMode: String = "",
            val gimbalPitchMode: String = "",
            val points: List<Point> = listOf()
        )

        data class Point(
            val pointId: String = "",
            val index: String = "",
            val name: String = "",
            val visibility: String = "",
            val description: String = "",
            val lng: Double = 0.0,
            val lat: Double = 0.0,
            val alt: Double = 0.0,
            val altitudeMode: String = "",
            val speed: Double = 0.0,
            val turnMode: String = "", //auto
            val useWayLineAltitude: String = "",

            val yawPitchArray: List<YawPitchArray> = listOf(),

            val shootingPointLng: String = "",
            val shootingPointLat: String = "",
            val shootingPointAlt: String = ""
        )

        data class YawPitchArray(
            val part: String = "",
            val aircraftYaw: Double = 0.0,
            val gimbalPitch: Double = 0.0,
            val captureCount: Int = 0
        )
    }




}